<?php

class business_finder_pleasebalance 
{
	var $column_control = '操作';
    var $column_control_width = 100;
    var $detail_basic = '基本信息';
 	function column_control($row){

		$pleasebalance = app::get('business')->model('pleasebalance');

        $pleasebalance_data = $pleasebalance->dump($row['pb_id'],'*');

       
            if($pleasebalance_data['status'] == 'ready'){
                return '<a href="index.php?app=business&ctl=admin_pleasebalance&act=toupdate&pb_id='.$row['pb_id'].'&finder_id='.$_GET['_finder']['finder_id'].'" target="dialog::{title:\'结算\'}" >'.app::get('business')->_('结算').'</a>';
            }else{
                return '<a>'.app::get('business')->_('已结算').'</a>';
            }
      
        }
    public function detail_basic($row)
    {

        $render =  app::get('business')->render();
        $order_bills = app::get('ectools')->model('order_bills');
        $obj_account = app::get('pam')->model('account');
        $pleasebalance = app::get('business')->model('pleasebalance');
        $refunds = app::get('ectools')->model('refunds');
        $order = app::get('b2c')->model('orders');
        $member = app::get('b2c')->model('members');
        //error_log(var_export($row,true),3,__FILE__.'.log');

        $pleasebalance_data = $pleasebalance->dump($row['pb_id'],'*');
        //error_log(var_export($pleasebalance_data,true),3,__FILE__.'.log');

        $reund_ids=explode('|',$pleasebalance_data['bigstr']);
        $list=$refunds->getList('*',array('refund_id|in'=>$reund_ids));
        //error_log(var_export($list,true),3,__FILE__.'.log');


        foreach($list as $key=>$value){

        $order_id = $order_bills->getList('rel_id',array('bill_id'=>$value['refund_id']));
        $member_id=$order->dump($order_id[0]['rel_id'],'member_id');
        $m_uname=$member->get_member_info($member_id['member_id']);
        $list[$key]['m_uname']=$m_uname['uname'];
        $list[$key]['order_id']=$order_id[0]['rel_id'];
        $uname = $obj_account->getRow('login_name',array('account_id'=>$value['op_id']));
        $list[$key]['uname'] = $uname['login_name'];
        $list[$key]['total']=$value['cur_money']+$value['profit']+$value['score_cost'];
        $all_profit=$value['profit']+$all_profit;
        $all_score_cost=$value['score_cost']+$all_score_cost;
        }
        $render->pagedata['list']=$list;
        $render->pagedata['all_total']= $pleasebalance_data['cur_money'];
        $render->pagedata['all_profit']=$all_profit;
        $render->pagedata['all_score_cost']=$all_score_cost;
        return $render->fetch('admin/pleasebalance/please_detail.html');

    }
        
}